package com.ptr.ptrsystem.dao;

/**
 *
 * @author pavel
 */
import com.ptr.ptrsystem.bean.*;
import com.ptr.ptrsystem.dao.*;
import java.sql.*;
import java.util.Vector;
import com.ptr.controladores.conexionsqlserver;

public class Buscar {

    public Buscar() {
    }
    Connection conn;
    CallableStatement cst;
    ResultSet rs;
    
    conexionsqlserver base=new conexionsqlserver();
    public Persona getBuscaPersona(String Acta)
    {
        Persona p=new Persona();
        try
        {
            base.conectar();
            conn=base.getconection();
            cst=conn.prepareCall("{call SP_BUSCARPERSONAACTA(?)}");
            cst.setString(1, Acta);
            rs=cst.executeQuery();
            if(rs.next())
            {
                p.setCOD_PERSONA(rs.getString(1));
                p.setPRIM_APE_PERS(rs.getString(2));
                p.setSEG_APE_PERS(rs.getString(3));
                p.setAPE_CASADA(rs.getString(4));
                p.setPRE_NOM_PERS(rs.getString(5));
                p.setIDUBIGEO_DOMICI(rs.getString(6));
                p.setCOD_DIR(rs.getString(7));
                p.setDIR_PERS(rs.getString(8));
                p.setNRO_DIR(rs.getString(9));
                p.setGEN_PERS(rs.getString(10));
                p.setFOTO_PERSONA(rs.getString(11));
                p.setTELEF_1(rs.getString(12));
                p.setTELEF_2(rs.getString(13));
                p.setEST_CIVIL_PERS(rs.getString(14));
                p.setCOD_NACIONALIDAD(rs.getString(15));
                p.setIDUBIGEO(rs.getString(16));
                p.setCOD_ESTADO_PERS(rs.getString(17));
                p.setCOD_CARGO(rs.getString(18));
            }
        }catch(SQLException e)
        {
            System.out.println("Este es un error en la busqueda de la Persona" + e.getMessage());
        } finally {
            return p;
        }
    }
public Persona getBuscaPersonaNac(String cui, String acta, String libro)
    {
        Persona p1=new Persona();
        try
        {
            base.conectar();
            conn=base.getconection();
            cst=conn.prepareCall("{call SP_BUSCAPERSONATIPO(?,?,?)}");
            cst.setString(1, cui);
            cst.setString(2, acta);
            cst.setString(3, libro);
            rs=cst.executeQuery();
            if(rs.next())
            {
                p1.setCOD_PERSONA(rs.getString(1));
                p1.setPRIM_APE_PERS(rs.getString(2));
                p1.setSEG_APE_PERS(rs.getString(3));
                p1.setAPE_CASADA(rs.getString(4));
                p1.setPRE_NOM_PERS(rs.getString(5));
                p1.setIDUBIGEO(rs.getString(6));
                p1.setCOD_DIR(rs.getString(7));
                p1.setDIR_PERS(rs.getString(8));
                p1.setNRO_DIR(rs.getString(9));
                p1.setGEN_PERS(rs.getString(10));
                p1.setFOTO_PERSONA(rs.getString(11));
                p1.setTELEF_1(rs.getString(12));
                p1.setTELEF_2(rs.getString(13));
                p1.setEST_CIVIL_PERS(rs.getString(14));
                p1.setCOD_NACIONALIDAD(rs.getString(15));
                p1.setIDUBIGEO(rs.getString(16));
                p1.setCOD_ESTADO_PERS(rs.getString(17));
                p1.setCOD_CARGO(rs.getString(18));
            }
        }catch(SQLException e)
        {
            System.out.println("Este es un error en la busqueda de la Persona" + e.getMessage());
        } finally {
            return p1;
        }
    }
    public NacimientoActa getBuscaNacimientoActa(String nroActa)
    {
        NacimientoActa nac=new NacimientoActa();
        try
        {
            base.conectar();
            conn=base.getconection();
            cst=conn.prepareCall("{call SP_BUSCARPERSONAACTA(?)}");
            cst.setString(1, nroActa);
            rs=cst.executeQuery();
            if(rs.next())
            {
                nac.setCUI_PERS(rs.getString(1));
                nac.setNRO_ACTA_PERS(rs.getString(2));
                nac.setNRO_LIBRO(rs.getString(3));
                nac.setDATOS(rs.getString(4));
                nac.setGEN_PERS(rs.getString(5));
                nac.setIDUBIGEO_DOMICI(rs.getString(6));
                nac.setCOD_DIR(rs.getString(7));
                nac.setDIR_PERS(rs.getString(8));
                nac.setNRO_DIR(rs.getString(9));
                nac.setIDUBIGEO(rs.getString(10));
                nac.setFECHA_NACIMIENTO(rs.getString(11));
                nac.setEST_CIVIL_PERS(rs.getString(12));
                nac.setCOD_ESTADO_PERS(rs.getString(13));
                nac.setRUTA_ACTA_NAC(rs.getString(14));
            }
        }catch(SQLException e)
        {
            System.out.println("Este es un error en la busqueda de la Persona" + e.getMessage());
        } finally {
            return nac;
        }
    }
}
